package entities;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.TreeSet;
// use Result only after the score for each entity is complete
public class Result {
	private Query q;
	// TreeSet<Entity> candidates;
	private ArrayList<Entity> candidates;
	@SuppressWarnings("unchecked")
	public Result(Query query, ArrayList<Entity> list){
		this.q = query;
		//this.candidates = new TreeSet<Entity>();
		//for( Entity e: list ){
			
	//		this.candidates.add(e);
			
	//	}
		this.candidates = list;
		Collections.sort(this.candidates);
	}
	public Query getQ() {
		return q;
	}
	public void setQ(Query q) {
		this.q = q;
	}
	public ArrayList<Entity> getCandidates() {
		return candidates;
	}
	
	public static void main(String[] args){
		
		Query q = new Query("eer","er","er",12,31);
		Entity e1 = new Entity("bbb");
		e1.setScore(0);
		Entity e2 = new Entity("dee");
		e2.setScore(0);
		Entity e3 = new Entity("er23");
		e3.setScore(0);
		ArrayList<Entity>  list= new ArrayList<Entity>();
		list.add(e3);
		list.add(e1);
		list.add(e2);
		
		Result re = new Result(q,list);
		ArrayList<Entity> es = re.getCandidates();
		Iterator<Entity> it = es.iterator();
		while( it.hasNext() ){
			Entity e = it.next();
			System.out.println(e.getName()+" "+e.getScore());
		}
		
	}

	
}
